package com.example.zhaoping.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.zhaoping.entity.User;
import com.example.zhaoping.mapper.UserMapper;
import com.example.zhaoping.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public int registerUser(User user) {
        return userMapper.insert(user);
    }
    @Override
    public User login(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",user.getUsername())
                .eq("password",user.getPassword());
        return userMapper.selectOne(queryWrapper);
    }
    @Override
    public User selectByUserName(User user){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",user.getUsername());
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public User selectByUserId(int id) {
        return userMapper.selectById(id);
    }

    @Override
    public User editUser(User user) {
        return null;
    }

    @Override
    public User deleteUser(Long id) {
        return null;
    }
}
